function insertTable10(tx, data) {
    $.each(data.consumptionRecords, function (i, item) {
        tx.executeSql("SELECT * FROM t_consumption_record WHERE id=" + item.id,
            [],
            function (tx, result) {
                if (result.rows.length > 0) {
                    tx.executeSql("UPDATE t_consumption_record SET id=" + item.id + ",appointment_id='" + item.appointmentId +
                        "',shop_id=" + item.shopId + ",product_name='" + item.productName + "',product_id=" + item.productId +
                        ",product_type=" + item.productType + ",product_count=" + item.productCount + ",customer_shop_id=" +
                        item.customerShopId + ",package_id=" + item.packageId + ",package_item_id=" + item.packageItemId +
                        ",original_price=" + item.originalPrice + ",actual_discount_rate=" + item.actualDiscountRate +
                        ",actual_price=" + item.actualPrice + ",payment_record_id=" + item.paymentRecordId +
                        ",appointed_dresser_id=" + item.appointedDresserId + ",actual_dresser_id=" + item.actualDresserId +
                        ",appointed_assist_id='" + item.appointedAssistId + "',assist_dresser_id='" + item.assistDresserId +
                        "',appointed_other_id='" + item.appointedOtherId + "',other_dresser_id='" + item.otherDresserId +
                        "',short_stay_status=" + item.shortStayStatus + ",consume_time='" + item.consumeTime.replace("+"," ") + "',update_time=" +
                        item.updateTime + ",del_status=" + (item.delStatus = true ? 0 : 1) + " WHERE id=" + item.id);
                } else {
                    tx.executeSql("INSERT INTO t_consumption_record (id,appointment_id,shop_id,product_name,product_id," +
                        "product_type,product_count,customer_shop_id,package_id,package_item_id,original_price," +
                        "actual_discount_rate,actual_price,payment_record_id,appointed_dresser_id,actual_dresser_id," +
                        "appointed_assist_id,assist_dresser_id,appointed_other_id,other_dresser_id,short_stay_status," +
                        "consume_time,update_time,del_status)VALUES (" + item.id + ",'" + item.appointmentId + "'," +
                        item.shopId + ",'" + item.productName + "'," + item.productId + "," + item.productType + "," +
                        item.productCount + "," + item.customerShopId + "," + item.packageId + "," + item.packageItemId +
                        "," + item.originalPrice + "," + item.actualDiscountRate + "," + item.actualPrice + "," +
                        item.paymentRecordId + "," + item.appointedDresserId + "," + item.actualDresserId + ",'" +
                        item.appointedAssistId + "','" + item.assistDresserId + "','" + item.appointedOtherId + "','" +
                        item.otherDresserId + "'," + item.shortStayStatus + ",'" + item.consumeTime.replace("+"," ") + "'," + item.updateTime +
                        "," + (item.delStatus = true ? 0 : 1) + ")");
                }
            });
    });
    $.each(data.cardRechargeRecords, function (i, item) {
        tx.executeSql("SELECT * FROM t_card_recharge_record WHERE id=" + item.id,
            [],
            function (tx, result) {
                if (result.rows.length > 0) {
                    tx.executeSql("UPDATE t_card_recharge_record SET id=" + item.id + ",shop_id=" + item.shopId +
                        ",card_id='" + item.cardId + "',customer_shop_id=" + item.customerShopId + ",package_id=" + item.packageId +
                        ",recharge_type=" + item.rechargeType + ",recharge_amount=" + item.rechargeAmount + ",extra_amount=" +
                        item.extraAmount + ",actual_price=" + item.actualPrice + ",payment_record_id=" + item.paymentRecordId +
                        ",credit_record_id='" + item.creditRecordId + "',achieve_dresser_id='" + item.achieveDresserId +
                        "',recharge_time='" + item.rechargeTime.replace("+", " ") + "',update_time=" + item.updateTime + ",del_status=" +
                        (item.delStatus = true ? 0 : 1) + " WHERE id=" + item.id);
                } else {
                    tx.executeSql("INSERT INTO t_card_recharge_record (id,shop_id,card_id,customer_shop_id,package_id," +
                        "recharge_type,recharge_amount,extra_amount,actual_price,payment_record_id,credit_record_id," +
                        "achieve_dresser_id,recharge_time,update_time,del_status) VALUES(" + item.id + "," + item.shopId +
                        ",'" + item.cardId + "'," + item.customerShopId + "," + item.packageId + "," + item.rechargeType +
                        "," + item.rechargeAmount + "," + item.extraAmount + "," + item.actualPrice + "," + item.paymentRecordId +
                        ",'" + item.creditRecordId + "','" + item.achieveDresserId + "','" + item.rechargeTime.replace("+", " ") + "'," +
                        item.updateTime + "," + (item.delStatus = true ? 0 : 1) + ")");
                }
            });
    });
    $.each(data.paymentRecords, function (i, item) {
        tx.executeSql("SELECT * FROM t_payment_record WHERE id=" + item.id,
            [],
            function (tx, result) {
                if (result.rows.length > 0) {
                    tx.executeSql("UPDATE t_payment_record SET id=" + item.id + ",card_id='" + item.cardId + "',shop_id=" +
                        item.shopId + ",customer_shop_id=" + item.customerShopId + ",payment_value=" + item.paymentValue +
                        ",payment_type=" + item.paymentType + ",payment_date='" + item.paymentDate.replace("+", " ") + "',update_time=" +
                        item.updateTime + ",del_status=" + (item.delStatus = true ? 0 : 1) + " WHERE id=" + item.id);
                } else {
                    tx.executeSql("INSERT INTO t_payment_record (id,card_id,shop_id,customer_shop_id,payment_value,payment_type," +
                        "payment_date,update_time,del_status) VALUES(" + item.id + ",'" + item.cardId +
                        "'," + item.shopId + "," + item.customerShopId + "," + item.paymentValue + "," + item.paymentType +
                        ",'" + item.paymentDate.replace("+", " ") + "'," + item.updateTime + "," + (item.delStatus = true ? 0 : 1) + ")");
                }
            });
    });
    $.each(data.creditRecords, function (i, item) {
        tx.executeSql("SELECT * FROM t_credit_record WHERE id=" + item.id,
            [],
            function (tx, result) {
                if (result.rows.length > 0) {
                    tx.executeSql("UPDATE t_credit_record SET id=" + item.id + ",shop_id=" + item.shopId +
                        ",card_id='" + item.cardId + "',customer_shop_id=" + item.customerShopId + ",owing_value=" + item.owingValue +
                        ",create_date='" + item.createDate.replace("+", " ") + "',repayed_value=" + item.repayedValue + ",repay_record_id='" +
                        item.repayRecordId + "',update_time=" + item.updateTime + ",del_status=" +
                        (item.delStatus = true ? 0 : 1) + " WHERE id=" + item.id);
                } else {
                    tx.executeSql("INSERT INTO t_credit_record (id,shop_id,card_id,customer_shop_id,owing_value,create_date,repayed_value" +
                        ",repay_record_id,update_time,del_status) VALUES(" + item.id + "," + item.shopId +
                        ",'" + item.cardId + "'," + item.customerShopId + "," + item.owingValue + ",'" + item.createDate.replace("+", " ") +
                        "'," + item.repayedValue + ",'" + item.repayRecordId + "'," + item.updateTime + "," + (item.delStatus = true ? 0 : 1) + ")");
                }
            });
    });
    $.each(data.repayRecords, function (i, item) {
        tx.executeSql("SELECT * FROM t_repay_record WHERE id=" + item.id,
            [],
            function (tx, result) {
                if (result.rows.length > 0) {
                    tx.executeSql("UPDATE t_repay_record SET id=" + item.id + ",card_id='" + item.cardId +
                        "',shop_id=" + item.shopId + ",customer_shop_id=" + item.customerShopId + ",repay_value=" + item.repayValue +
                        ",repay_type=" + item.repayType + ",repay_date='" + item.repayTime.replace("+", " ") + "',update_time=" + item.updateTime +
                        ",del_status=" + (item.delStatus = true ? 0 : 1) + " WHERE id=" + item.id);
                } else {
                    tx.executeSql("INSERT INTO t_repay_record (id,card_id,shop_id,customer_shop_id,repay_value,repay_type," +
                        "repay_date,update_time,del_status) VALUES(" + item.id + ",'" + item.cardId +
                        "'," + item.shopId + "," + item.customerShopId + "," + item.repayValue + "," + item.repayType +
                        ",'" + item.repayTime.replace("+", " ") + "'," + item.updateTime + "," + (item.delStatus = true ? 0 : 1) + ")");
                }
            });
    });
    $.each(data.extraFinancialRecords, function (i, item) {
        tx.executeSql("SELECT * FROM t_extra_financial_record WHERE id=" + item.id,
            [],
            function (tx, result) {
                if (result.rows.length > 0) {
                    tx.executeSql("UPDATE t_extra_financial_record SET id=" + item.id + ",shop_id=" + item.shopId +
                        ",pay_value=" + item.payValue + ",earning_value=" + item.earningValue +
                        ",remark='" + item.remark.replace(/\+/g, " ").replace(/\'/g,"&apos;").replace(/\"/g,"&quot;") + "',create_time='" + item.createTime.replace("+", " ") + "',update_time=" + item.updateTime +
                        ",del_status=" + (item.delStatus = true ? 0 : 1) + " WHERE id=" + item.id);
                } else {
                    tx.executeSql("INSERT INTO t_extra_financial_record (id,shop_id,pay_value,earning_value,remark,create_time," +
                        "update_time,del_status) VALUES(" + item.id + "," + item.shopId + "," + item.payValue + "," +
                        item.earningValue + ",'" + item.remark.replace(/\+/g, " ").replace(/\'/g,"&apos;").replace(/\"/g,"&quot;") + "','" + item.createTime.replace("+", " ") + "'," + item.updateTime + "," +
                        (item.delStatus = true ? 0 : 1) + ")");
                }
            });
    });
    var updateTime=data.updateTime;
    updateSyncTable(tx,10,updateTime);
}
function insertTable9(tx, data) {
    $.each(data.customerPackageItems, function (i, item) {
        tx.executeSql("SELECT * FROM t_customer_package_item WHERE id=" + item.id,
            [],
            function (tx, result) {
                if (result.rows.length > 0) {
                    tx.executeSql("UPDATE t_customer_package_item SET id=" + item.id + ",shop_id=" + item.shopId +
                        ",description='" + item.description.replace(/\+/g, " ").replace(/\'/g,"&apos;").replace(/\"/g,"&quot;") + "',product_id=" + item.productId + ",type=" +
                        item.type + ",times=" + item.times + ",conversion_price=" + item.conversionPrice +
                        ",discount_rate=" + item.discountRate + ",update_time=" + item.updateTime + ",del_status=" +
                        (item.delStatus = true ? 0 : 1) + " WHERE id=" + item.id);

                } else {
                    tx.executeSql("INSERT INTO t_customer_package_item(id,shop_id,description,product_id," +
                        "type,times,conversion_price,discount_rate,update_time,del_status)" +
                        "VALUES(" + item.id + "," + item.shopId + ",'" + item.description.replace(/\+/g, " ").replace(/\'/g,"&apos;").replace(/\"/g,"&quot;") + "'," + item.productId + "," + item.type +
                        "," + item.times + "," + item.conversionPrice + "," + item.discountRate + "," + item.updateTime +
                        "," + (item.delStatus = true ? 0 : 1) + ")");
                }
            }
        )
        ;
    });
    $.each(data.packageModelItems, function (i, item) {
        tx.executeSql("SELECT * FROM t_package_model_item WHERE id=" + item.id,
            [],
            function (tx, result) {
                if (result.rows.length > 0) {
                    tx.executeSql("UPDATE t_package_model_item SET id=" + item.id + ",shop_id=" + item.shopId +
                        ",description='" + item.description.replace(/\+/g, " ").replace(/\'/g,"&apos;").replace(/\"/g,"&quot;") + "',product_id=" + item.productId + ",type=" +
                        item.type + ",times=" + item.times + ",conversion_price=" + item.conversionPrice +
                        ",discount_rate=" + item.discountRate + ",update_time=" + item.updateTime + ",del_status=" +
                        (item.delStatus = true ? 0 : 1) + " WHERE id=" + item.id);

                } else {
                    tx.executeSql("INSERT INTO t_package_model_item(id,shop_id,description,product_id,type,times," +
                        "conversion_price,discount_rate,update_time,del_status)" +
                        "VALUES(" + item.id + "," + item.shopId + ",'" + item.description.replace(/\+/g, " ").replace(/\'/g,"&apos;").replace(/\"/g,"&quot;") + "'," + item.productId + "," + item.type +
                        "," + item.times + "," + item.conversionPrice + "," + item.discountRate + "," + item.updateTime +
                        "," + (item.delStatus = true ? 0 : 1) + ")");
                }
            }
        )
        ;
    });
    $.each(data.customerPackages, function (i, item) {
        tx.executeSql("SELECT * FROM t_customer_package WHERE id=" + item.id,
            [],
            function (tx, result) {
                if (result.rows.length > 0) {
                    tx.executeSql("UPDATE t_customer_package SET id=" + item.id + ",shop_id=" + item.shopId +
                        ",name='" + item.name + "',price=" + item.price + ",available_balance=" +
                        item.availableBalance + ",item_ids='" + item.itemIds + "',start_time='" +
                        item.startTime.replace("+", " ") + "',end_time='" + item.endTime.replace("+", " ") +
                        "',update_time=" + item.updateTime + ",del_status=" + (item.delStatus = true ? 0 : 1) +
                        ",model_id=" + item.modelId +",customer_shop_id=" + item.customerShopId + " WHERE id=" + item.id);

                } else {
                    tx.executeSql("INSERT INTO t_customer_package(id,shop_id,name,price,available_balance," +
                        "item_ids,start_time,end_time,update_time,del_status,model_id,customer_shop_id)" +
                        "VALUES(" + item.id + "," + item.shopId + ",'" + item.name + "'," + item.price +
                        "," + item.availableBalance + ",'" + item.itemIds + "','" + item.startTime.replace("+", " ") +
                        "','" + item.endTime.replace("+", " ") + "'," + item.updateTime + "," +
                        (item.delStatus = true ? 0 : 1) + "," + item.modelId +"," + item.customerShopId + ")");
                }
            }
        );
    });
    $.each(data.packageModels, function (i, item) {
        tx.executeSql("SELECT * FROM t_package_model WHERE id=" + item.id,
            [],
            function (tx, result) {
                if (result.rows.length > 0) {
                    tx.executeSql("UPDATE t_package_model SET id=" + item.id + ",shop_id=" + item.shopId +
                        ",name='" + item.name + "',price=" + item.price + ",available_balance=" +
                        item.availableBalance + ",item_ids='" + item.itemIds + "',start_time='" +
                        item.startTime.replace("+", " ") + "',end_time='" + item.endTime.replace("+", " ") +
                        "',update_time=" + item.updateTime + ",del_status=" + (item.delStatus = true ? 0 : 1) +
                        " WHERE id=" + item.id);

                } else {
                    tx.executeSql("INSERT INTO t_package_model(id,shop_id,name,price,available_balance,item_ids," +
                        "start_time,end_time,update_time,del_status)" +
                        "VALUES(" + item.id + "," + item.shopId + ",'" + item.name + "'," + item.price +
                        "," + item.availableBalance + ",'" + item.itemIds + "','" + item.startTime.replace("+", " ") +
                        "','" + item.endTime.replace("+", " ") + "'," + item.updateTime + "," +
                        (item.delStatus = true ? 0 : 1) + ")");
                }
            }
        );
    });
    $.each(data.packageChangeRecords, function (i, item) {
        tx.executeSql("SELECT * FROM t_package_change_record WHERE id=" + item.id,
            [],
            function (tx, result) {
                if (result.rows.length > 0) {
                    tx.executeSql("UPDATE t_package_change_record SET id=" + item.id + ",shop_id=" + item.shopId +
                        ",customer_name='" + item.customerName + "',customer_card='" + item.customerCard + "',customer_cellphone='" +
                        item.customerCellphone + "',primary_package_name='" + item.primaryPackageName + "',primary_package_id=" +
                        item.primaryPackageId + ",primary_available_balance=" + item.primaryAvailableBalance + ",new_package_name='" +
                        item.newPackageName + "',new_package_id=" + item.newPackageId + ",new_available_balance=" +
                        item.newAvailableBalance + ",remark='" + item.remark.replace(/\+/g, " ").replace(/\'/g,"&apos;").replace(/\"/g,"&quot;") + "',update_time=" + item.updateTime +
                        ",del_status=" + (item.delStatus = true ? 0 : 1) + " WHERE id=" + item.id);

                } else {
                    tx.executeSql("INSERT INTO t_package_change_record(id,shop_id,customer_name,customer_card," +
                        "customer_cellphone,primary_package_name,primary_package_id,primary_available_balance," +
                        "new_package_name,new_package_id,new_available_balance,remark,update_time,del_status)" +
                        "VALUES(" + item.id + "," + item.shopId + ",'" + item.customerName + "','" + item.customerCard +
                        "','" + item.customerCellphone + "','" + item.primaryPackageName + "'," + item.primaryPackageId +
                        "," + item.primaryAvailableBalance + ",'" + item.newPackageName + "'," + item.newPackageId +
                        "," + item.newAvailableBalance + ",'" + item.remark.replace(/\+/g, " ").replace(/\'/g,"&apos;").replace(/\"/g,"&quot;") + "'," + item.updateTime + "," +
                        (item.delStatus = true ? 0 : 1) + ")");
                }
            }
        );
    });
    $.each(data.packageEnchashmentRecords, function (i, item) {
        tx.executeSql("SELECT * FROM t_package_enchashment_record WHERE id=" + item.id,
            [],
            function (tx, result) {
                if (result.rows.length > 0) {
                    tx.executeSql("UPDATE t_package_enchashment_record SET id=" + item.id + ",shop_id=" + item.shopId +
                        ",customer_name='" + item.customerName + "',customer_card='" + item.customerCard + "',customer_cellphone='" +
                        item.customerCellphone + "',package_name='" + item.packageName + "',package_id=" +
                        item.packageId + ",available_balance=" + item.availableBalance + ",enchash_value=" +
                        item.enchashValue + ",update_time=" + item.updateTime + ",del_status=" + (item.delStatus = true ? 0 : 1) +
                        ",remark='" + item.remark.replace(/\+/g, " ").replace(/\'/g,"&apos;").replace(/\"/g,"&quot;") +"' WHERE id=" + item.id);

                } else {
                    tx.executeSql("INSERT INTO t_package_enchashment_record(id,shop_id,customer_name,customer_card," +
                        "customer_cellphone,package_name,package_id,available_balance,enchash_value,update_time,del_status,remark)" +
                        "VALUES(" + item.id + "," + item.shopId + ",'" + item.customerName + "','" + item.customerCard +
                        "','" + item.customerCellphone + "','" + item.packageName + "'," + item.packageId +
                        "," + item.availableBalance + "," + item.enchashValue + "," + item.updateTime + "," +
                        (item.delStatus = true ? 0 : 1) + ",'" + item.remark.replace(/\+/g, " ").replace(/\'/g,"&apos;").replace(/\"/g,"&quot;") +"')");
                }
            }
        );
    });
    $.each(data.packageFreezeRecords, function (i, item) {
        tx.executeSql("SELECT * FROM t_package_freeze_record WHERE id=" + item.id,
            [],
            function (tx, result) {
                if (result.rows.length > 0) {
                    tx.executeSql("UPDATE t_package_freeze_record SET id=" + item.id + ",shop_id=" + item.shopId +
                        ",customer_name='" + item.customerName + "',customer_card='" + item.customerCard + "',customer_cellphone='" +
                        item.customerCellphone + "',package_name='" + item.packageName + "',package_id=" + item.packageId +
                        ",available_balance=" + item.availableBalance + ",freeze_date='" + item.freezeDate.replace("+", " ") +
                        "',unfreeze_date='" + item.unfreezeDate.replace("+", " ") + "',freeze_status=" + item.freezeStatus +
                        ",remark='" + item.remark.replace(/\+/g, " ").replace(/\'/g,"&apos;").replace(/\"/g,"&quot;") + "',update_time=" + item.updateTime + ",del_status=" +
                        (item.delStatus = true ? 0 : 1) + " WHERE id=" + item.id);

                } else {
                    tx.executeSql("INSERT INTO t_package_freeze_record(id,shop_id,customer_name,customer_card,customer_cellphone," +
                        "package_name,package_id,available_balance,freeze_date,unfreeze_date,freeze_status,remark,update_time,del_status )" +
                        "VALUES(" + item.id + "," + item.shopId + ",'" + item.customerName + "','" + item.customerCard + "','" +
                        item.customerCellphone + "','" + item.packageName + "'," + item.packageId + "," + item.availableBalance +
                        ",'" + item.freezeDate.replace("+", " ") + "','" + item.unfreezeDate.replace("+", " ") + "'," + item.freezeStatus +
                        ",'" + item.remark.replace(/\+/g, " ").replace(/\'/g,"&apos;").replace(/\"/g,"&quot;") + "'," + item.updateTime + "," + (item.delStatus = true ? 0 : 1) + ")");
                }
            }
        );
    });
    $.each(data.packageTransferRecords, function (i, item) {
        tx.executeSql("SELECT * FROM t_package_transfer_record WHERE id=" + item.id,
            [],
            function (tx, result) {
                if (result.rows.length > 0) {
                    tx.executeSql("UPDATE t_package_transfer_record SET id=" + item.id + ",shop_id=" + item.shopId +
                        ",primary_customer_name='" + item.primaryCustomerName + "',primary_customer_card='" +
                        item.primaryCustomerCard + "',primary_customer_cellphone='" + item.primaryCustomerCellphone +
                        "',package_name='" + item.packageName + "',package_id=" + item.packageId + ",available_balance=" +
                        item.availableBalance + ",new_customer_name='" + item.newCustomerName + "',new_customer_card='" +
                        item.newCustomerCard + "',new_customer_cellphone='" + item.newCustomerCellphone + "',update_time=" +
                        item.updateTime + ",del_status=" + (item.delStatus = true ? 0 : 1) + ",remark='" +
                        item.remark.replace(/\+/g, " ").replace(/\'/g,"&apos;").replace(/\"/g,"&quot;") +"' WHERE id=" + item.id);

                } else {
                    tx.executeSql("INSERT INTO t_package_transfer_record(id,shop_id,primary_customer_name," +
                        "primary_customer_card,primary_customer_cellphone,package_name,package_id,available_balance," +
                        "new_customer_name,new_customer_card,new_customer_cellphone,update_time,del_status,remark)" +
                        "VALUES(" + item.id + "," + item.shopId + ",'" + item.primaryCustomerName + "','" + item.primaryCustomerCard +
                        "','" + item.primaryCustomerCellphone + "','" + item.packageName + "'," + item.packageId +
                        "," + item.availableBalance + ",'" + item.newCustomerName + "','"+ item.newCustomerCard +
                        "','"+ item.newCustomerCellphone + "'," + item.updateTime + "," + (item.delStatus = true ? 0 : 1) +
                        ",'" + item.remark.replace(/\+/g, " ").replace(/\'/g,"&apos;").replace(/\"/g,"&quot;") +"')");
                }
            }
        );
    });
    var updateTime=data.updateTime;
    updateSyncTable(tx,9,updateTime);
}
function insertTable8(tx, data) {
    $.each(data.appointments, function (i, item) {
        tx.executeSql("SELECT * FROM t_appointment WHERE id='" + item.id + "'",
            [],
            function (tx, result) {
                if (result.rows.length > 0) {
                    tx.executeSql("UPDATE t_appointment SET id='" + item.id + "',shop_id=" + item.shopId + ",update_time=" + item.updateTime + ",plat=" +
                        item.plat + ",appoint_time='" + item.appointTime.replace("+", " ") + "',del_status=" + (item.delStatus = true ? 0 : 1) + ",items_id='" + item.itemsId +
                        "',total_fee=" + item.totalFee + " WHERE id='" + item.id + "'");

                } else {
                    tx.executeSql("INSERT INTO t_appointment(id,shop_id,update_time,plat,appoint_time,del_status,items_id,total_fee)" +
                        "VALUES('" + item.id + "'," + item.shopId + "," + item.updateTime + "," + item.plat + ",'" + item.appointTime.replace("+", " ") + "'," + (item.delStatus = true ? 0 : 1) +
                        ",'" + item.itemsId + "'," + item.totalFee + ")");
                }
            });

    });
    $.each(data.appointmentitems, function (i, item) {
        tx.executeSql("SELECT * FROM t_appointment_item WHERE id=" + item.id,
            [],
            function (tx, result) {
                if (result.rows.length > 0) {
                    tx.executeSql("UPDATE t_appointment_item SET id=" + item.id + ",comment_id='" + item.commentId + "',cost_time=" +
                        item.costTime + ",customer_id=" + item.customerId + ",del_status=" + (item.delStatus = true ? 0 : 1) + ",hairdresser_id=" +
                        item.hairdresserId + ",pay_status=" + item.payStatus + ",hairshop_id=" + item.hairshopId + ",plat=" +
                        item.plat + ",price=" + item.price + ",product_id=" + item.productId + ",product_name='" + item.productName +
                        "',start_time='" + item.startTime + "',status=" + item.status + ",update_time=" + item.updateTime +
                        " WHERE id=" + item.id);
                } else {
                    tx.executeSql("INSERT INTO t_appointment_item (id,comment_id,cost_time,customer_id,del_status,hairdresser_id," +
                        "pay_status,hairshop_id,plat,price,product_id,product_name,start_time,status,update_time)" +
                        "VALUES (" + item.id + ",'" + item.commentId + "'," + item.costTime + "," + item.customerId + "," + (item.delStatus = true ? 0 : 1) + "," +
                        item.hairdresserId + "," + item.payStatus + "," + item.hairshopId + "," + item.plat + "," + item.price + "," + item.productId +
                        ",'" + item.productName + "','" + item.startTime + "'," + item.status + "," + item.updateTime + ")");
                }

            }
        )
        $.each(item.commentIds, function (j, ite) {
            tx.executeSql("SELECT * FROM t_comment WHERE id=" + ite.id,
                [],
                function (tx, result) {
                    if (result.rows.length > 0) {
                        tx.executeSql("UPDATE t_comment SET id=" + ite.id + ",commenter_id=" + ite.commenterId + ",commenter_type=" +
                            ite.commenterType + ",content='" + ite.content.replace(/\+/g, " ").replace(/\'/g,"&apos;").replace(/\"/g,"&quot;") + "',del_status=" + (ite.delStatus = true ? 0 : 1) + ",score=" +
                            ite.score + ",update_time=" + ite.updateTime + " WHERE id=" + ite.id);
                    } else {
                        tx.executeSql("INSERT INTO t_comment" +
                            "(id, commenter_id, commenter_type,content,del_status,score,update_time)" +
                            "VALUES (" + ite.id + "," + ite.commenterId + "," + ite.commenterType + ",'" +
                            ite.content.replace(/\+/g, " ").replace(/\'/g,"&apos;").replace(/\"/g,"&quot;") + "'," + (ite.delStatus = true ? 0 : 1) + "," + ite.score + "," + ite.updateTime + ")");
                    }
                }
            )
        });
    });
    var updateTime=data.updateTime;
    updateSyncTable(tx,8,updateTime);
}
function insertTable7(tx, data) {
    $.each(data.customerShops, function (i, item) {
        tx.executeSql("SELECT * FROM t_customer_shop WHERE id=" + item.id,
            [],
            function (tx, result) {
                if (result.rows.length > 0) {
                    tx.executeSql("UPDATE t_customer_shop SET id=" + item.id + ",cellphone='" + item.cellphone + "',name='" + item.name + "',shop_id='" +
                        item.shopId + "',credit=" + item.credit + ",last_access_time='" + item.lastAccessTime.replace("+", " ") + "',last_product_name='" + item.lastProductName +
                        "',last_product_id='" + item.lastProductId + "',register_date='" + item.registerDate.replace("+", " ") + "',remind_time='" + item.remindTime + "',remind_status=" +
                        item.remindStatus + ",appointment_count=" + item.appointmentCount + ",comment_id='" + item.commentId + "',gender=" + item.gender +
                        ",age='" + item.age.replace(/\+/g, "") + "',birthday='" + item.birthday + "',update_time=" + item.updateTime + ",del_status=" +
                        (item.delStatus = true ? 0 : 1) + ",recommend_customer_id=" + item.recommendCustomerId + ",card_id='" + item.cardId + "',package_ids='" + item.packageIds +
                        "',credit_line=" + item.creditLine + " WHERE id=" + item.id);

                } else {
                    tx.executeSql("INSERT INTO t_customer_shop(id, cellphone,name,shop_id,credit,last_access_time,last_product_name,last_product_id," +
                        "register_date,remind_time,remind_status,appointment_count,comment_id,gender," +
                        "age,birthday,update_time,del_status,recommend_customer_id,card_id,package_ids,credit_line)" +
                        "VALUES(" + item.id + ",'" + item.cellphone + "','"+item.name+"','" + item.shopId + "'," + item.credit + ",'" + item.lastAccessTime.replace("+", " ") +
                        "','" + item.lastProductName + "','" + item.lastProductId + "','" + item.registerDate.replace("+", " ") + "','" + item.remindTime + "'," + item.remindStatus +
                        "," + item.appointmentCount + ",'" + item.commentId + "'," + item.gender + ",'" + item.age.replace(/\+/g, "") + "','" + item.birthday + "'," + item.updateTime +
                        "," + (item.delStatus = true ? 0 : 1) + "," + item.recommendCustomerId + ",'" + item.cardId + "','" + item.packageIds + "'," + item.creditLine + ")");
                }
            });
        $.each(item.customercomment, function (j, ite) {
            tx.executeSql("SELECT * FROM t_customer_comment WHERE id=" + ite.id,
                [],
                function (tx, result) {
                    if (result.rows.length > 0) {
                        tx.executeSql("UPDATE t_customer_comment SET id=" + ite.id + ",comment_by=" + ite.commentBy + ",content='" +
                            ite.content.replace(/\+/g, " ").replace(/\'/g,"&apos;").replace(/\"/g,"&quot;") + "',del_status=" + (ite.delStatus = true ? 0 : 1) + ",update_time=" + ite.updateTime + " WHERE id=" + ite.id);

                    } else {
                        tx.executeSql("INSERT INTO t_customer_comment(id, comment_by, content,del_status, update_time)" +
                            "VALUES(" + ite.id + "," + ite.commentBy + ",'" + ite.content.replace(/\+/g, " ").replace(/\'/g,"&apos;").replace(/\"/g,"&quot;") + "'," + (ite.delStatus = true ? 0 : 1) + "," + ite.updateTime + ")");
                    }
                });
        });

    });
    $.each(data.customerWechat, function (i, item) {
        tx.executeSql("SELECT * FROM t_customer_wechat WHERE id=" + item.id,
            [],
            function (tx, result) {
                if (result.rows.length > 0) {
                    tx.executeSql("UPDATE t_customer_wechat SET id=" + item.id + ",age='" + item.age.replace(/\+/g, "") + "',appointment_count=" + item.appointmentCount + ",birthday='" +
                        item.birthday + "',cellphone='" + item.cellphone + "',continuous_sign_times=" + item.continuousSignTimes + ",credit=" + item.credit +
                        ",del_status=" + (item.delStatus = true ? 0 : 1) + ",first_attention_time='" + item.firstAttentionTime.replace("+", " ") + "',gender=" + item.gender + ",last_interview_mills=" +
                        item.lastInterviewMills + ",last_sign_date='" + item.lastSignDate.replace("+", " ") + "',name='" + item.name + "',open_id='" + item.openId +
                        "',pay_attention=" + item.payAttention + ",shop_id='" + item.shopId + "',update_time=" + item.updateTime + ",head_img_url='" +
                        item.headImgUrl + "' WHERE id=" + item.id);

                } else {
                    tx.executeSql("INSERT INTO t_customer_wechat(id,age,appointment_count,birthday,cellphone," +
                        "continuous_sign_times,credit,del_status,first_attention_time,gender,last_interview_mills," +
                        "last_sign_date,name,open_id,pay_attention,shop_id,update_time,head_img_url)" +
                        "VALUES(" + item.id + ",'" + item.age.replace(/\+/g, "") + "'," + item.appointmentCount + ",'" + item.birthday + "','" + item.cellphone +
                        "'," + item.continuousSignTimes + "," + item.credit + "," + (item.delStatus = true ? 0 : 1) + ",'" + item.firstAttentionTime.replace("+", " ") +
                        "'," + item.gender + "," + item.lastInterviewMills + ",'" + item.lastSignDate.replace("+", " ") + "','aaaa','" + item.openId +
                        "'," + item.payAttention + ",'" + item.shopId + "'," + item.updateTime + ",'" + item.headImgUrl + "')");
                }
            });
    });
    $.each(data.customerShopToWechat, function (i, item) {
        tx.executeSql("SELECT * FROM t_customer_shop_to_wechat WHERE id=" + item.id,
            [],
            function (tx, result) {
                if (result.rows.length > 0) {
                    tx.executeSql("UPDATE t_customer_shop_to_wechat SET id=" + item.id + ",customer_shop_id='" + item.customerShopId + "',customer_wechat_id='" +
                        item.customerWechatId + "',shop_id='" + item.shopId + "',open_id='" + item.openId + "',update_time=" + item.updateTime + " WHERE id=" + item.id);

                } else {
                    tx.executeSql("INSERT INTO t_customer_shop_to_wechat(id, customer_shop_id, customer_wechat_id,shop_id, open_id, update_time)" +
                        "VALUES(" + item.id + ",'" + item.customerShopId + "','" + item.customerWechatId + "','" + item.shopId + "','" + item.openId + "'," + item.updateTime + ")");
                }
            });
    });
    var updateTime=data.updateTime;
    updateSyncTable(tx,7,updateTime);
}
function insertTable5(tx, data){
    $.each(data.hairshops, function (i, item) {
        var id = item.id;
        var address = item.address.replace(/\+/g, " ");
        var area = item.area.replace(/\+/g, " ");
        var closeTime = item.closeTime;
        var delStatus = (item.delStatus=true?0:1);
        var examineStatus = item.examineStatus;
        var hot = item.hot;
        var introduction = item.introduction.replace(/\+/g, " ");
        var keeperTle = item.keeperTel;
        var latitude = item.latitude;
        var longitude = item.longitude;
        var mediaIds = item.mediaIds;
        var multiple = item.multiple;
        var multipleId = item.multipleId;
        var name = item.name;
        var openTime = item.openTime;
        var shopKeeper = item.shopKeeper;
        var shopTel = item.shopTel;
        var shopWecharId = item.shopWecharId;
        var updateTime = item.updateTime;
        tx.executeSql("SELECT * FROM t_hairshop WHERE id="+id,
            [],
            function(tx,result){
                if(result.rows.length>0){
                    tx.executeSql("UPDATE t_hairshop SET id="+id+",address='"+address+"',area='"+
                        area+"',close_time='"+closeTime+"',del_status="+delStatus+",examine_status='"+
                        examineStatus+"',hot="+hot+",introduction='"+introduction+"',keeper_tel='"+keeperTle+"',latitude='"+
                        latitude+"',longitude='"+longitude+"',media_ids='"+mediaIds+"',multiple='"+multiple+"',multiple_id='"+
                        multipleId+"',name='"+name+"',open_time='"+openTime+"',shop_keeper='"+shopKeeper+"',shop_tel='"+
                        shopTel+"',shop_wechar_id="+shopWecharId+",update_time="+updateTime+" WHERE id="+id);
                }else{
                    tx.executeSql("INSERT INTO t_hairshop(id, address,area,close_time,del_status,examine_status,hot," +
                        "introduction,keeper_tel,latitude,longitude,media_ids,multiple,multiple_id,name,open_time," +
                        "shop_keeper,shop_tel,shop_wechar_id, update_time)" +
                        "VALUES (" + id + ",'" + address + "','" + area + "','" + closeTime + "'," + delStatus + ",'" + examineStatus +
                        "'," + hot + ",'" + introduction + "','" + keeperTle + "','" + latitude + "','" + longitude + "','" + mediaIds +
                        "','" + multiple + "','" + multipleId + "','" + name + "','" + openTime + "','" + shopKeeper + "','" + shopTel +
                        "'," + shopWecharId + "," + updateTime + ")");
                }
            }
        )
    });
    $.each(data.media, function (i, ite) {
        var baseCode = ite.baseCode;
        var baseMedia = ite.baseMedia;
        var delStatus = (ite.delStatus = true ? 0 : 1);
        var id = ite.id;
        var mediaType = ite.mediaType;
        var shrinkCode = ite.shrinkCode;
        var shrinkMedia = ite.shrinkMedia;
        var updateTime = ite.updateTime;
        tx.executeSql("SELECT * FROM t_multimedia WHERE id="+id,
            [],
            function(tx,result){
                if(result.rows.length>0){
                    tx.executeSql("UPDATE t_multimedia SET id="+id+",del_status="+delStatus+",base_code='"+
                        baseCode+"',base_media='"+baseMedia+"',media_type="+mediaType+",shrink_code='"+
                        shrinkCode+"',shrink_media='"+shrinkMedia+"',update_time="+updateTime+" WHERE id="+id);
                }else{
                    tx.executeSql("INSERT INTO t_multimedia (id, base_code,base_media,del_status,media_type," +
                        "shrink_code,shrink_media, update_time) VALUES (" + id + ",'" + baseCode + "','" +
                        baseMedia + "'," + delStatus + "," + mediaType + ",'" + shrinkCode + "','" +
                        shrinkMedia + "'," + updateTime + ")");
                }
            }
        )
    });
    var updateTime=data.updateTime;
    updateSyncTable(tx,5,updateTime);
}
function insertTable4(tx, data){
    $.each(data.schedules, function (i, item) {
        var id = item.id;
        var delStatus = (item.delStatus = true ? 0 : 1);
        var hairdresserId = item.hairdresserId;
        var shopId = item.shopId;
        var updateTime = item.updateTime;
        var workStatus = item.workStatus;
        var date = item.date;
        tx.executeSql("SELECT * FROM t_schedule WHERE id="+id,
            [],
            function(tx,result){
                if(result.rows.length>0){
                    tx.executeSql("UPDATE t_schedule SET id="+id+",del_status="+delStatus+",date='"+
                        date+"',hairdresser_id="+hairdresserId+",shop_id="+shopId+",update_time="+
                        updateTime+",work_status="+workStatus+" WHERE id="+id);
                }else{
                    tx.executeSql("INSERT INTO t_schedule(id, date,del_status,hairdresser_id, shop_id," +
                        " update_time,work_status) VALUES (" + id + ",'" + date + "'," + delStatus +
                        "," + hairdresserId + "," + shopId + "," + updateTime + "," + workStatus + ")");
                }
            }
        )
    });
    var updateTime=data.updateTime;
    updateSyncTable(tx,4,updateTime);
}
function insertTable3(tx, data){
    $.each(data.relations, function (i, item) {
        var id = item.id;
        var delStatus = (item.delStatus = true ? 0 : 1);
        var hairdresserId = item.hairdresserId;
        var productId = item.productId;
        var updateTime = item.updateTime;
        tx.executeSql("SELECT * FROM t_hairdresser_product WHERE id="+id,
            [],
            function(tx,result){
                if(result.rows.length>0){
                    tx.executeSql("UPDATE t_hairdresser_product SET id="+id+",del_status="+delStatus+",hairdresser_id="+
                        hairdresserId+",product_id="+productId+",update_time="+updateTime+" WHERE id="+id);
                }else{
                    tx.executeSql("INSERT INTO t_hairdresser_product(id, del_status,hairdresser_id, product_id, update_time)" +
                        "VALUES (" + id + "," + delStatus + "," + hairdresserId + "," + productId + "," + updateTime + ")");
                }
            }
        )
    });
    var updateTime=data.updateTime;
    updateSyncTable(tx,3,updateTime);
}
function insertTable2(tx, data){
    $.each(data.products, function (i, item) {
        var id = item.id;
        var delStatus = (item.delStatus = true ? 0 : 1);
        var description = item.description.replace(/\+/g, " ").replace(/\'/g,"&apos;").replace(/\"/g,"&quot;");
        var examineStatus = item.examineStatus;
        var haiishopId = item.hairshopId;
        var horizontalMediaId = item.horizontalMediaId;
        var name = item.name;
        var price = item.price;
        var remindCircle = item.remindCircle;
        var sort = item.sort;
        var time = item.time;
        var type = item.type;
        var updateTime = item.updateTime;
        var verticalMediaId = item.verticalMediaId;
        tx.executeSql('SELECT * FROM t_product WHERE id='+id,
            [],
            function(tx,result){
                if(result.rows.length>0){
                    tx.executeSql("UPDATE t_product SET id="+id+",del_status="+delStatus+",description='"+
                        description+"',examine_status='"+examineStatus+"',hairshop_id="+haiishopId+",horizontal_media_id='"+
                        horizontalMediaId+"',name='"+name+"',price="+price+",remind_circle="+remindCircle+",sort="+
                        sort+",time="+time+",type="+type+",update_time="+
                        updateTime+",vertical_media_id='"+verticalMediaId+"' WHERE id="+id);
                }else{
                    tx.executeSql("INSERT INTO t_product (id, del_status,description,examine_status,hairshop_id,horizontal_media_id,name,price," +
                        "remind_circle,sort,time,type,update_time,vertical_media_id) VALUES (" + id + "," + delStatus + ",'" + description +
                        "','" + examineStatus + "'," + haiishopId + ",'" + horizontalMediaId + "','" + name + "'," + price + "," + remindCircle +
                        "," + sort + "," + time + "," + type + "," + updateTime + ",'" + verticalMediaId + "')");
                }

            }
        )
        $.each(item.media, function (i, ite) {
            var baseCode = ite.baseCode;
            var baseMedia = ite.baseMedia;
            var delStatus = (ite.delStatus = true ? 0 : 1);
            var id = ite.id;
            var mediaType = ite.mediaType;
            var shrinkCode = ite.shrinkCode;
            var shrinkMedia = ite.shrinkMedia;
            var updateTime = ite.updateTime;
            tx.executeSql("SELECT * FROM t_multimedia WHERE id="+id,
                [],
                function(tx,result){
                    if(result.rows.length>0){
                        tx.executeSql("UPDATE t_multimedia SET id="+id+",del_status="+delStatus+",base_code='"+
                            baseCode+"',base_media='"+baseMedia+"',media_type="+mediaType+",shrink_code='"+
                            shrinkCode+"',shrink_media='"+shrinkMedia+"',update_time="+updateTime+" WHERE id="+id);
                    }else{
                        tx.executeSql("INSERT INTO t_multimedia (id, base_code,base_media,del_status,media_type," +
                            "shrink_code,shrink_media, update_time)" +
                            "VALUES (" + id + ",'" + baseCode + "','" + baseMedia + "'," + delStatus + "," + mediaType +
                            ",'" + shrinkCode + "','" + shrinkMedia + "'," + updateTime + ")");
                    }
                }
            )
        });
    });
    var updateTime=data.updateTime;
    updateSyncTable(tx,2,updateTime);
}
function insertTable1(tx, data) {
    $.each(data.dressers, function (i, item) {
        var id = item.id;
        var delStatus = (item.delStatus = true ? 0 : 1);
        var dresserIntro = item.dresserIntro.replace(/\+/g, " ");
        var dresserTel = item.dresserTel;
        var examineStatus = item.examineStatus;
        var hairshopId = item.hairshopId;
        var mediaId = item.mediaId;
        var name = item.name;
        var position = item.position;
        var sort = item.sort;
        var updateTime = item.updateTime;
        var workExperienceId = item.workExperienceId;
        var workId = item.workId;
        tx.executeSql('SELECT * FROM t_hairdresser WHERE id='+id,
            [],
            function(tx,result){
                if(result.rows.length>0){
                    tx.executeSql("UPDATE t_hairdresser SET id="+id+",del_status="+delStatus+",dresser_intro='"+
                        dresserIntro+"',dresser_tel='"+dresserTel+"',examine_status='"+examineStatus+"',hairshop_id="+
                        hairshopId+",media_id='"+mediaId+"',name='"+name+"',position='"+position+"',sort="+
                        sort+",update_time="+updateTime+",work_experience_id='"+workExperienceId+"',work_id='"+
                        workId+"' WHERE id="+id);
                }else{
                    tx.executeSql("INSERT INTO t_hairdresser" +
                        "(id, del_status,dresser_intro,dresser_tel,examine_status,hairshop_id,media_id,name," +
                        "position,sort, update_time,work_experience_id,work_id)" +
                        "VALUES (" + id + "," + delStatus + ",'" + dresserIntro + "','" + dresserTel + "','" +
                        examineStatus + "'," + hairshopId + ",'" + mediaId + "','" + name + "','" + position +
                        "'," + sort + "," + updateTime + ",'" + workExperienceId + "','" + workId + "')");
                }

            }
        )
        var works = item.works;
        tx.executeSql('SELECT * FROM t_works WHERE id='+works.id,
            [],
            function(tx,result){
                if(result.rows.length>0){
                    tx.executeSql("UPDATE t_works SET id="+works.id+",del_status="+(works.delStatus = true ? 0 : 1)+",description='"+
                        works.description.replace(/\+/g, " ").replace(/\'/g,"&apos;").replace(/\"/g,"&quot;")+"',media_id='"+works.mediaId+"',name='"+works.name+"',update_time="+
                        works.updateTime+" WHERE id="+works.id);
                }else{
                    tx.executeSql("INSERT INTO t_works(id, del_status, description,media_id,name, update_time)" +
                        "VALUES (" + works.id + "," + (works.delStatus = true ? 0 : 1) + ",'" + works.description.replace(/\+/g, " ").replace(/\'/g,"&apos;").replace(/\"/g,"&quot;") +
                        "','" + works.mediaId + "','" + works.name + "'," + works.updateTime + ")");
                }
            }
        );

        $.each(item.media, function (j, ite) {
            var baseCode = ite.baseCode;
            var baseMedia = ite.baseMedia;
            var delStatus = (ite.delStatus = true ? 0 : 1);
            var id = ite.id;
            var mediaType = ite.mediaType;
            var shrinkCode = ite.shrinkCode;
            var shrinkMedia = ite.shrinkMedia;
            var updateTime = ite.updateTime;
            tx.executeSql('SELECT * FROM t_multimedia WHERE id='+id,
                [],
                function(tx,result){
                    if(result.rows.length>0){
                        tx.executeSql("UPDATE t_multimedia SET id="+id+",del_status="+delStatus+",base_code='"+
                            baseCode+"',base_media='"+baseMedia+"',media_type="+mediaType+",shrink_code='"+
                            shrinkCode+"',shrink_media='"+shrinkMedia+"',update_time="+updateTime+" WHERE id="+id);
                    }else{
                        tx.executeSql("INSERT INTO t_multimedia " +
                            "(id, base_code,base_media,del_status,media_type,shrink_code,shrink_media, update_time)" +
                            "VALUES (" + id + ",'" + baseCode + "','" + baseMedia +"'," + delStatus + "," + mediaType +
                            ",'" + shrinkCode + "','" + shrinkMedia + "'," + updateTime + ")");
                    }
                }
            )
        });
        $.each(item.workExperience, function (k, ites) {
            var content = ites.content.replace(/\+/g, " ").replace(/\'/g,"&apos;").replace(/\"/g,"&quot;");
            var delStatus = (ites.delStatus = true ? 0 : 1);
            var endTime = ites.endTime;
            var id = ites.id;
            var startTime = ites.startTime;
            var updateTime = ites.updateTime;
            tx.executeSql('SELECT * FROM t_work_experience WHERE id='+id,
                [],
                function(tx,result){
                    if(result.rows.length>0){
                        tx.executeSql("UPDATE t_work_experience SET id="+id+",del_status="+delStatus+",content='"+
                            content+"',end_time='"+endTime+"',start_time='"+startTime+"',update_time="+
                            updateTime+" WHERE id="+id);
                    }else{
                        tx.executeSql("INSERT INTO t_work_experience(id, content,del_status,end_time,start_time, update_time)" +
                            "VALUES (" + id + ",'" + content + "'," + delStatus + ",'" + endTime + "','" + startTime +
                            "'," + updateTime + ")");
                    }
                }
            )

        });
    });
    var updateTime=data.updateTime;
    updateSyncTable(tx,1,updateTime);
}

function getUpdateTimeByModule(module){
    var ids;
    var mods;
    var updates;
    var up;
    $.each(msg.modules, function (i,item) {
        ids=item.id;
        mods=item.module;
        updates=item.updateTime;
        if(module==mods){
            up=updates;
        }
    })
    return up;
}
var shopIdU;
function getData(shopId,module,updateTime) {
    shopIdU=shopId;
    var getMsg;
    $.ajax({
        type: 'POST',
        url: 'getData.do?shopId='+shopId+'&module='+module+'&updateTime='+updateTime,
        dataType: 'text',
        contentType: "application/x-www-form-urlencoded; charset=utf-8",
        async: false,
        error: function (msg) {
            alert(msg + "这里么？");
        },
        success: function (msg) {
            getMsg = msg;
        }
    });
    return getMsg;
}
function updateSyncTable(tx,module,updateTime){
    tx.executeSql('UPDATE t_syncinfo SET update_time='+updateTime+' WHERE shop_id='+shopIdU+' AND module='+module);
}
